﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SyringeControl
{
    /// <summary>
    /// Interface of a source of controls that are tested.
    /// Can check whether it can create an instance of given type.
    /// </summary>
    public interface IControlFactory
    {
        /// <summary>
        /// Checks whether <see cref="IControlFactory"/> can create an instance of given type
        /// </summary>
        /// <param name="type">type, instance of which needs to be created</param>
        /// <returns>true if this factory can create instance of given type</returns>
        bool IsValid(Type type);
        /// <summary>
        /// Creates instance of type <paramref name="type"/>.
        /// </summary>
        /// <param name="type">type, instance of which needs to be created</param>
        /// <returns>instance of given control type.</returns>
        /// <exception cref="ArgumentException"> if <paramref name="type"/> cannot be instantiated by this factory</exception>
        /// <remarks>Use <see cref="IControlFactory.IsValid"/> to check whether this method will succeed</remarks>
        Control Create(Type type);
    }
}
